package com.tanxin.bill.modules.adapter;

import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;

import com.allen.library.SuperTextView;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tanxin.bill.R;
import com.tanxin.bill.common.data.BillData;

import java.util.List;

public class BillAdapter extends BaseQuickAdapter<BillData,BaseViewHolder> {

    public BillAdapter(@Nullable List<BillData> data) {
        super(R.layout.bill_recycle_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BillData item) {
        SuperTextView tvBill = helper.getView(R.id.tv_bill);
        tvBill.setLeftString(item.getCustomerDataToOne().getTarget().getName())
                .setLeftBottomString(TimeUtils.date2String(item.getHandleData()))
                .setRightString(String.valueOf(item.getMoney()));

        if (item.getType()== BillData.Type.LOAN){
            tvBill.setRightTextColor(ContextCompat.getColor(mContext,R.color.colorLoan));
        }else {
            tvBill.setRightTextColor(ContextCompat.getColor(mContext,R.color.colorRepay));
        }

    }
}
